<template>
  <div>
    <div class="column">
      <div class="orderCard">
        <div class="addressBar">
          <div class="address">
            <div class="font18">{{ currentOrder.store.storeName }}</div>
            <div class="font_gray11">
              {{ currentOrder.store.address }}
            </div>
          </div>
          <div class="imgs">
            <img src="@/assets/img/order/icon_map.png" alt="" />
            <img src="@/assets/img/order/icon_phone.png" alt="" />
          </div>
        </div>
        <div
          class="commodities"
          v-for="(commodity, index) in currentOrder.commodityList"
          :key="index"
        >
          <div class="left">
            <van-image
              width="100%"
              height="100%"
              fit="cover"
              :src="commodity.imgUrl"
            />
          </div>
          <div class="middle">
            <div class="font16">{{ commodity.commodityName }}</div>
            <div class="font_gray11">{{ commodity.properties }}</div>
          </div>
          <div class="right">
            <div class="price">￥{{ commodity.price }}</div>
            <div class="count">共{{ commodity.count }}件</div>
          </div>
        </div>
        <div class="price">
          <div class="left">
            <div>
              共<span class="bold16">{{ totalCount(currentOrder) }}</span
              >件
            </div>
            <div>
              ￥<span class="bold16">{{ currentOrder.totalPrice }}</span>
            </div>
          </div>
          <div class="right">再来一单</div>
        </div>
      </div>
      <div class="orderCard">
        <div class="addressBar">
          <div class="address">
            <div class="font18">订单信息</div>
          </div>
        </div>
        <div class="orderInformation">
          <div>
            下单时间: <span>{{ currentOrder.date }}</span>
          </div>
          <div>
            订单编号: <span>{{ currentOrder.orderId }}</span>
          </div>
          <div>
            备注信息: <span>{{ currentOrder.remark }}</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Vue from "vue";
import { Image as VanImage, List, Overlay } from "vant";

Vue.use(VanImage).use(Overlay);
export default {
  name: "orderCard",
  props: {
    currentOrder: Object,
  },
  methods: {
    totalCount(order) {
      var sum = 0;
      for (let index = 0; index < order.commodityList.length; index++) {
        const element = order.commodityList[index];
        sum = parseInt(sum) + parseInt(element.count);
      }
      return sum;
    },
  },
};
</script>

<style scoped>
.orderCard {
  min-height: 1rem;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  margin: 0.3rem 0.5rem 0 0.5rem;
  padding: 0.5rem;
  border-radius: 10px;
}
.font16 {
  font-size: 16px;
}
.font18 {
  font-size: 18px;
}
.addressBar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  border-bottom: 1px solid #f9f9f9;
  padding-bottom: 0.5rem;
}
.addressBar .address {
  width: 65%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.addressBar .imgs {
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
}
.addressBar .imgs img {
  width: 1rem;
  height: 1rem;
  margin: 0 0 0 0.3rem;
}
/* 商品列表 */
.orderCard .commodities {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  box-sizing: border-box;
  widows: 100%;
  margin-top: 0.3rem;
  border-bottom: 1px solid #f9f9f9;
  padding-bottom: 0.5rem;
}
.orderCard .commodities .left {
  width: 15%;
  min-height: 1.5rem;
  margin-right: 0.3rem;
}
.orderCard .commodities .middle {
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin: 0 0.3rem;
}
.orderCard .commodities .right {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: right;
}
.orderCard .commodities .right .price {
  font-size: 16px;
  color: #333;
}
.orderCard .commodities .right .count {
  font-size: 12px;
  color: gray;
  min-height: 0.8rem;
  margin-top: 0.1rem;
}
.orderCard .price {
  margin-top: 0.6rem;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
}
.orderCard .price .left {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  width: 30%;
  line-height: 0.8rem;
  font-size: 14px;
}
.orderCard .price .right {
  border-radius: 2px;
  width: 2.4rem;
  height: 0.8rem;
  text-align: center;
  line-height: 0.8rem;
  border: 1px solid #dba871;
  color: #dba871;
  font-size: 14px;
}
.orderCard .orderInformation {
  display: flex;
  flex-direction: column;
}
.orderCard .orderInformation div {
  color: gray;
  margin: 0.3rem 0 0 0;
  font-size: 14px;
}
.orderCard .orderInformation div span {
  margin-left: 0.2rem;
  color: #333;
}
</style>